﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Tests.Integration.Instruments;
using System.Diagnostics;
using System.IO;
using White.Core;
using White.Core.Factory;
using White.Core.UIItems;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Tests.Integration.Commands
{
    [TestClass]
    public class ConfigureSolutionCommandTest : FxCopIntegratorTestAutomaterBase
    {
        [TestMethod]
        [HostType("VS IDE")]
        public void ExecuteShouldShowSolutionConfigurationEditor()
        {
            RunOnUIThread(() =>
            {
                OpenSolution(Path.Combine("ConfigureSolutionCommand", "solution", "solution.sln"));
                SelectSolutionItem("solution");
                ExecuteCommand<ConfigureSolutionCommand>(new UIControlAction(2000, () =>
                {
                    var application = Application.Attach(Process.GetCurrentProcess());
                    var window = application.Find(o => o == "Code Analysis Configuration Editor", InitializeOption.NoCache);
                    var button = window.Get<Button>("cancelButton");
                    button.RaiseClickEvent();
                    //var window = Application.Current.GetWindow<SolutionConfigurationEditorWindow>();
                    //var button = window.Get<Button>("cancelButton");
                    //button.PerformClick();
                }));
            });
        }
    }
}
